---触发器管理器，管理代理所持有的触发器
---@class TriggerManagerBase
---@field agent AgentBase
---@field triggers TriggerBase[]
---@field base TriggerManagerBase
TriggerManagerBase = class()

---@param agent AgentBase
function TriggerManagerBase:ctor(agent)
    self.base = TriggerManagerBase;
    self.agent = agent;
    self.triggers = {}
    self:InitTriggers();
end

---所有需要添加的触发器在此函数内进行添加，子类重写
function TriggerManagerBase:InitTriggers() end

---帧函数
function TriggerManagerBase:FramFun()
    for i, v in ipairs(self.triggers) do
        v:FrameFun();
    end
end

---@param triggerType type
function TriggerManagerBase:AddTrigger(triggerType)
    local trigger = self.agent.dataMap:GetTrigger(triggerType);
    table.insert(self.triggers,trigger);
    table.sort(self.triggers,function (a,b)
        return a.priority > b.priority;
    end)
end